*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Hopkins 2014 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/hopkins365.html
*******************************************************************************************************************************
*******************************************************************************************************************************
* The logic of the analysis was inspired by the layout of the data and code for the data and code for...
* "The Hidden American Immigration Consensus: A Conjoint Analysis of Attitudes toward Immigrants"...
* by Jens Hainmueller (co-author Daniel J. Hopkins)
* doi:10.7910/DVN/25505, Harvard Dataverse, V1, UNF:5:tevlw4dhO6Evym2pA6vSZg== 
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "F:Tess3_145_Hopkins_Client.dta"

set more off
sum CaseID
di 14*r(N)
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
append using "F:\2011-04\ljz\papers\0 working projects\0 under review\22 racial discrimination\data\0-bw samples\17-hopkins 2014-03\Tess3_145_Hopkins_Client.dta"
sum CaseID
sort CaseID

gen candidate = mod(_n, 14)
recode candidate (0=14)

gen choice = .

recode choice (.=1) if Q1==1 & candidate==1
recode choice (.=0) if Q1==2 & candidate==1
recode choice (.=1) if Q1==2 & candidate==2
recode choice (.=0) if Q1==1 & candidate==2

recode choice (.=1) if Q5==1 & candidate==3
recode choice (.=0) if Q5==2 & candidate==3
recode choice (.=1) if Q5==2 & candidate==4
recode choice (.=0) if Q5==1 & candidate==4

recode choice (.=1) if Q8==1 & candidate==5
recode choice (.=0) if Q8==2 & candidate==5
recode choice (.=1) if Q8==2 & candidate==6
recode choice (.=0) if Q8==1 & candidate==6

recode choice (.=1) if Q11==1 & candidate==7
recode choice (.=0) if Q11==2 & candidate==7
recode choice (.=1) if Q11==2 & candidate==8
recode choice (.=0) if Q11==1 & candidate==8

recode choice (.=1) if Q14==1 & candidate==9
recode choice (.=0) if Q14==2 & candidate==9
recode choice (.=1) if Q14==2 & candidate==10
recode choice (.=0) if Q14==1 & candidate==10

recode choice (.=1) if Q17==1 & candidate==11
recode choice (.=0) if Q17==2 & candidate==11
recode choice (.=1) if Q17==2 & candidate==12
recode choice (.=0) if Q17==1 & candidate==12

recode choice (.=1) if Q26==1 & candidate==13
recode choice (.=0) if Q26==2 & candidate==13
recode choice (.=1) if Q26==2 & candidate==14
recode choice (.=0) if Q26==1 & candidate==14

gen rating = .

replace rating=Q2 if Q2>0 & candidate==1
replace rating=Q3 if Q3>0 & candidate==2

replace rating=Q6 if Q6>0 & candidate==3
replace rating=Q7 if Q7>0 & candidate==4

replace rating=Q9 if Q9>0 & candidate==5
replace rating=Q10 if Q10>0 & candidate==6

replace rating=Q12 if Q12>0 & candidate==7
replace rating=Q13 if Q13>0 & candidate==8

replace rating=Q15 if Q12>0 & candidate==9
replace rating=Q16 if Q13>0 & candidate==10

replace rating=Q24 if Q12>0 & candidate==11
replace rating=Q25 if Q13>0 & candidate==12

replace rating=Q27 if Q12>0 & candidate==13
replace rating=Q28 if Q13>0 & candidate==14

gen cFemale = .
recode cFemale (.=1) if candidate==1 & A7_Can1_Table1==2
recode cFemale (.=0) if candidate==1 & A7_Can1_Table1==1
recode cFemale (.=1) if candidate==2 & A7_Can2_Table1==2
recode cFemale (.=0) if candidate==2 & A7_Can2_Table1==1
recode cFemale (.=1) if candidate==3 & A7_Can3_Table2==2
recode cFemale (.=0) if candidate==3 & A7_Can3_Table2==1
recode cFemale (.=1) if candidate==4 & A7_Can4_Table2==2
recode cFemale (.=0) if candidate==4 & A7_Can4_Table2==1
recode cFemale (.=1) if candidate==5 & A7_Can5_Table3==2
recode cFemale (.=0) if candidate==5 & A7_Can5_Table3==1
recode cFemale (.=1) if candidate==6 & A7_Can6_Table3==2
recode cFemale (.=0) if candidate==6 & A7_Can6_Table3==1
recode cFemale (.=1) if candidate==7 & A7_Can7_Table4==2
recode cFemale (.=0) if candidate==7 & A7_Can7_Table4==1
recode cFemale (.=1) if candidate==8 & A7_Can8_Table4==2
recode cFemale (.=0) if candidate==8 & A7_Can8_Table4==1
recode cFemale (.=1) if candidate==9 & A7_Can9_Table5==2
recode cFemale (.=0) if candidate==9 & A7_Can9_Table5==1
recode cFemale (.=1) if candidate==10 & A7_Can10_Table5==2
recode cFemale (.=0) if candidate==10 & A7_Can10_Table5==1
recode cFemale (.=1) if candidate==11 & A7_Can11_Table6==2
recode cFemale (.=0) if candidate==11 & A7_Can11_Table6==1
recode cFemale (.=1) if candidate==12 & A7_Can12_Table6==2
recode cFemale (.=0) if candidate==12 & A7_Can12_Table6==1
recode cFemale (.=1) if candidate==13 & A7_Can13_Table7==2
recode cFemale (.=0) if candidate==13 & A7_Can13_Table7==1
recode cFemale (.=1) if candidate==14 & A7_Can14_Table7==2
recode cFemale (.=0) if candidate==14 & A7_Can14_Table7==1

gen cHispn = .
recode cHispn (.=1) if candidate==1 & A6_Can1_Table1==1
recode cHispn (.=0) if candidate==1 & A6_Can1_Table1!=1
recode cHispn (.=1) if candidate==2 & A6_Can2_Table1==1
recode cHispn (.=0) if candidate==2 & A6_Can2_Table1!=1
recode cHispn (.=1) if candidate==3 & A6_Can3_Table2==1
recode cHispn (.=0) if candidate==3 & A6_Can3_Table2!=1
recode cHispn (.=1) if candidate==4 & A6_Can4_Table2==1
recode cHispn (.=0) if candidate==4 & A6_Can4_Table2!=1
recode cHispn (.=1) if candidate==5 & A6_Can5_Table3==1
recode cHispn (.=0) if candidate==5 & A6_Can5_Table3!=1
recode cHispn (.=1) if candidate==6 & A6_Can6_Table3==1
recode cHispn (.=0) if candidate==6 & A6_Can6_Table3!=1
recode cHispn (.=1) if candidate==7 & A6_Can7_Table4==1
recode cHispn (.=0) if candidate==7 & A6_Can7_Table4!=1
recode cHispn (.=1) if candidate==8 & A6_Can8_Table4==1
recode cHispn (.=0) if candidate==8 & A6_Can8_Table4!=1
recode cHispn (.=1) if candidate==9 & A6_Can9_Table5==1
recode cHispn (.=0) if candidate==9 & A6_Can9_Table5!=1
recode cHispn (.=1) if candidate==10 & A6_Can10_Table5==1
recode cHispn (.=0) if candidate==10 & A6_Can10_Table5!=1
recode cHispn (.=1) if candidate==11 & A6_Can11_Table6==1
recode cHispn (.=0) if candidate==11 & A6_Can11_Table6!=1
recode cHispn (.=1) if candidate==12 & A6_Can12_Table6==1
recode cHispn (.=0) if candidate==12 & A6_Can12_Table6!=1
recode cHispn (.=1) if candidate==13 & A6_Can13_Table7==1
recode cHispn (.=0) if candidate==13 & A6_Can13_Table7!=1
recode cHispn (.=1) if candidate==14 & A6_Can14_Table7==1
recode cHispn (.=0) if candidate==14 & A6_Can14_Table7!=1

gen cWhite = .
recode cWhite (.=1) if candidate==1 & A6_Can1_Table1==2
recode cWhite (.=0) if candidate==1 & A6_Can1_Table1!=2
recode cWhite (.=1) if candidate==2 & A6_Can2_Table1==2
recode cWhite (.=0) if candidate==2 & A6_Can2_Table1!=2
recode cWhite (.=1) if candidate==3 & A6_Can3_Table2==2
recode cWhite (.=0) if candidate==3 & A6_Can3_Table2!=2
recode cWhite (.=1) if candidate==4 & A6_Can4_Table2==2
recode cWhite (.=0) if candidate==4 & A6_Can4_Table2!=2
recode cWhite (.=1) if candidate==5 & A6_Can5_Table3==2
recode cWhite (.=0) if candidate==5 & A6_Can5_Table3!=2
recode cWhite (.=1) if candidate==6 & A6_Can6_Table3==2
recode cWhite (.=0) if candidate==6 & A6_Can6_Table3!=2
recode cWhite (.=1) if candidate==7 & A6_Can7_Table4==2
recode cWhite (.=0) if candidate==7 & A6_Can7_Table4!=2
recode cWhite (.=1) if candidate==8 & A6_Can8_Table4==2
recode cWhite (.=0) if candidate==8 & A6_Can8_Table4!=2
recode cWhite (.=1) if candidate==9 & A6_Can9_Table5==2
recode cWhite (.=0) if candidate==9 & A6_Can9_Table5!=2
recode cWhite (.=1) if candidate==10 & A6_Can10_Table5==2
recode cWhite (.=0) if candidate==10 & A6_Can10_Table5!=2
recode cWhite (.=1) if candidate==11 & A6_Can11_Table6==2
recode cWhite (.=0) if candidate==11 & A6_Can11_Table6!=2
recode cWhite (.=1) if candidate==12 & A6_Can12_Table6==2
recode cWhite (.=0) if candidate==12 & A6_Can12_Table6!=2
recode cWhite (.=1) if candidate==13 & A6_Can13_Table7==2
recode cWhite (.=0) if candidate==13 & A6_Can13_Table7!=2
recode cWhite (.=1) if candidate==14 & A6_Can14_Table7==2
recode cWhite (.=0) if candidate==14 & A6_Can14_Table7!=2

gen cBlack = .
recode cBlack (.=1) if candidate==1 & A6_Can1_Table1==3
recode cBlack (.=0) if candidate==1 & A6_Can1_Table1!=3
recode cBlack (.=1) if candidate==2 & A6_Can2_Table1==3
recode cBlack (.=0) if candidate==2 & A6_Can2_Table1!=3
recode cBlack (.=1) if candidate==3 & A6_Can3_Table2==3
recode cBlack (.=0) if candidate==3 & A6_Can3_Table2!=3
recode cBlack (.=1) if candidate==4 & A6_Can4_Table2==3
recode cBlack (.=0) if candidate==4 & A6_Can4_Table2!=3
recode cBlack (.=1) if candidate==5 & A6_Can5_Table3==3
recode cBlack (.=0) if candidate==5 & A6_Can5_Table3!=3
recode cBlack (.=1) if candidate==6 & A6_Can6_Table3==3
recode cBlack (.=0) if candidate==6 & A6_Can6_Table3!=3
recode cBlack (.=1) if candidate==7 & A6_Can7_Table4==3
recode cBlack (.=0) if candidate==7 & A6_Can7_Table4!=3
recode cBlack (.=1) if candidate==8 & A6_Can8_Table4==3
recode cBlack (.=0) if candidate==8 & A6_Can8_Table4!=3
recode cBlack (.=1) if candidate==9 & A6_Can9_Table5==3
recode cBlack (.=0) if candidate==9 & A6_Can9_Table5!=3
recode cBlack (.=1) if candidate==10 & A6_Can10_Table5==3
recode cBlack (.=0) if candidate==10 & A6_Can10_Table5!=3
recode cBlack (.=1) if candidate==11 & A6_Can11_Table6==3
recode cBlack (.=0) if candidate==11 & A6_Can11_Table6!=3
recode cBlack (.=1) if candidate==12 & A6_Can12_Table6==3
recode cBlack (.=0) if candidate==12 & A6_Can12_Table6!=3
recode cBlack (.=1) if candidate==13 & A6_Can13_Table7==3
recode cBlack (.=0) if candidate==13 & A6_Can13_Table7!=3
recode cBlack (.=1) if candidate==14 & A6_Can14_Table7==3
recode cBlack (.=0) if candidate==14 & A6_Can14_Table7!=3

gen cAsian = .
recode cAsian (.=1) if candidate==1 & A6_Can1_Table1==4
recode cAsian (.=0) if candidate==1 & A6_Can1_Table1!=4
recode cAsian (.=1) if candidate==2 & A6_Can2_Table1==4
recode cAsian (.=0) if candidate==2 & A6_Can2_Table1!=4
recode cAsian (.=1) if candidate==3 & A6_Can3_Table2==4
recode cAsian (.=0) if candidate==3 & A6_Can3_Table2!=4
recode cAsian (.=1) if candidate==4 & A6_Can4_Table2==4
recode cAsian (.=0) if candidate==4 & A6_Can4_Table2!=4
recode cAsian (.=1) if candidate==5 & A6_Can5_Table3==4
recode cAsian (.=0) if candidate==5 & A6_Can5_Table3!=4
recode cAsian (.=1) if candidate==6 & A6_Can6_Table3==4
recode cAsian (.=0) if candidate==6 & A6_Can6_Table3!=4
recode cAsian (.=1) if candidate==7 & A6_Can7_Table4==4
recode cAsian (.=0) if candidate==7 & A6_Can7_Table4!=4
recode cAsian (.=1) if candidate==8 & A6_Can8_Table4==4
recode cAsian (.=0) if candidate==8 & A6_Can8_Table4!=4
recode cAsian (.=1) if candidate==9 & A6_Can9_Table5==4
recode cAsian (.=0) if candidate==9 & A6_Can9_Table5!=4
recode cAsian (.=1) if candidate==10 & A6_Can10_Table5==4
recode cAsian (.=0) if candidate==10 & A6_Can10_Table5!=4
recode cAsian (.=1) if candidate==11 & A6_Can11_Table6==4
recode cAsian (.=0) if candidate==11 & A6_Can11_Table6!=4
recode cAsian (.=1) if candidate==12 & A6_Can12_Table6==4
recode cAsian (.=0) if candidate==12 & A6_Can12_Table6!=4
recode cAsian (.=1) if candidate==13 & A6_Can13_Table7==4
recode cAsian (.=0) if candidate==13 & A6_Can13_Table7!=4
recode cAsian (.=1) if candidate==14 & A6_Can14_Table7==4
recode cAsian (.=0) if candidate==14 & A6_Can14_Table7!=4


gen CDemL = .
recode CDemL (.=1) if candidate==1 & A1_Can1_Table1==1
recode CDemL (.=0) if candidate==1 & A1_Can1_Table1!=1
recode CDemL (.=1) if candidate==2 & A1_Can2_Table1==1
recode CDemL (.=0) if candidate==2 & A1_Can2_Table1!=1
recode CDemL (.=1) if candidate==3 & A1_Can3_Table2==1
recode CDemL (.=0) if candidate==3 & A1_Can3_Table2!=1
recode CDemL (.=1) if candidate==4 & A1_Can4_Table2==1
recode CDemL (.=0) if candidate==4 & A1_Can4_Table2!=1
recode CDemL (.=1) if candidate==5 & A1_Can5_Table3==1
recode CDemL (.=0) if candidate==5 & A1_Can5_Table3!=1
recode CDemL (.=1) if candidate==6 & A1_Can6_Table3==1
recode CDemL (.=0) if candidate==6 & A1_Can6_Table3!=1
recode CDemL (.=1) if candidate==7 & A1_Can7_Table4==1
recode CDemL (.=0) if candidate==7 & A1_Can7_Table4!=1
recode CDemL (.=1) if candidate==8 & A1_Can8_Table4==1
recode CDemL (.=0) if candidate==8 & A1_Can8_Table4!=1
recode CDemL (.=1) if candidate==9 & A1_Can9_Table5==1
recode CDemL (.=0) if candidate==9 & A1_Can9_Table5!=1
recode CDemL (.=1) if candidate==10 & A1_Can10_Table5==1
recode CDemL (.=0) if candidate==10 & A1_Can10_Table5!=1
recode CDemL (.=1) if candidate==11 & A1_Can11_Table6==1
recode CDemL (.=0) if candidate==11 & A1_Can11_Table6!=1
recode CDemL (.=1) if candidate==12 & A1_Can12_Table6==1
recode CDemL (.=0) if candidate==12 & A1_Can12_Table6!=1
recode CDemL (.=1) if candidate==13 & A1_Can13_Table7==1
recode CDemL (.=0) if candidate==13 & A1_Can13_Table7!=1
recode CDemL (.=1) if candidate==14 & A1_Can14_Table7==1
recode CDemL (.=0) if candidate==14 & A1_Can14_Table7!=1

gen CDemM = .
recode CDemM (.=1) if candidate==1 & A1_Can1_Table1==2
recode CDemM (.=0) if candidate==1 & A1_Can1_Table1!=2
recode CDemM (.=1) if candidate==2 & A1_Can2_Table1==2
recode CDemM (.=0) if candidate==2 & A1_Can2_Table1!=2
recode CDemM (.=1) if candidate==3 & A1_Can3_Table2==2
recode CDemM (.=0) if candidate==3 & A1_Can3_Table2!=2
recode CDemM (.=1) if candidate==4 & A1_Can4_Table2==2
recode CDemM (.=0) if candidate==4 & A1_Can4_Table2!=2
recode CDemM (.=1) if candidate==5 & A1_Can5_Table3==2
recode CDemM (.=0) if candidate==5 & A1_Can5_Table3!=2
recode CDemM (.=1) if candidate==6 & A1_Can6_Table3==2
recode CDemM (.=0) if candidate==6 & A1_Can6_Table3!=2
recode CDemM (.=1) if candidate==7 & A1_Can7_Table4==2
recode CDemM (.=0) if candidate==7 & A1_Can7_Table4!=2
recode CDemM (.=1) if candidate==8 & A1_Can8_Table4==2
recode CDemM (.=0) if candidate==8 & A1_Can8_Table4!=2
recode CDemM (.=1) if candidate==9 & A1_Can9_Table5==2
recode CDemM (.=0) if candidate==9 & A1_Can9_Table5!=2
recode CDemM (.=1) if candidate==10 & A1_Can10_Table5==2
recode CDemM (.=0) if candidate==10 & A1_Can10_Table5!=2
recode CDemM (.=1) if candidate==11 & A1_Can11_Table6==2
recode CDemM (.=0) if candidate==11 & A1_Can11_Table6!=2
recode CDemM (.=1) if candidate==12 & A1_Can12_Table6==2
recode CDemM (.=0) if candidate==12 & A1_Can12_Table6!=2
recode CDemM (.=1) if candidate==13 & A1_Can13_Table7==2
recode CDemM (.=0) if candidate==13 & A1_Can13_Table7!=2
recode CDemM (.=1) if candidate==14 & A1_Can14_Table7==2
recode CDemM (.=0) if candidate==14 & A1_Can14_Table7!=2

gen CMod = .
recode CMod (.=1) if candidate==1 & A1_Can1_Table1==3
recode CMod (.=0) if candidate==1 & A1_Can1_Table1!=3
recode CMod (.=1) if candidate==2 & A1_Can2_Table1==3
recode CMod (.=0) if candidate==2 & A1_Can2_Table1!=3
recode CMod (.=1) if candidate==3 & A1_Can3_Table2==3
recode CMod (.=0) if candidate==3 & A1_Can3_Table2!=3
recode CMod (.=1) if candidate==4 & A1_Can4_Table2==3
recode CMod (.=0) if candidate==4 & A1_Can4_Table2!=3
recode CMod (.=1) if candidate==5 & A1_Can5_Table3==3
recode CMod (.=0) if candidate==5 & A1_Can5_Table3!=3
recode CMod (.=1) if candidate==6 & A1_Can6_Table3==3
recode CMod (.=0) if candidate==6 & A1_Can6_Table3!=3
recode CMod (.=1) if candidate==7 & A1_Can7_Table4==3
recode CMod (.=0) if candidate==7 & A1_Can7_Table4!=3
recode CMod (.=1) if candidate==8 & A1_Can8_Table4==3
recode CMod (.=0) if candidate==8 & A1_Can8_Table4!=3
recode CMod (.=1) if candidate==9 & A1_Can9_Table5==3
recode CMod (.=0) if candidate==9 & A1_Can9_Table5!=3
recode CMod (.=1) if candidate==10 & A1_Can10_Table5==3
recode CMod (.=0) if candidate==10 & A1_Can10_Table5!=3
recode CMod (.=1) if candidate==11 & A1_Can11_Table6==3
recode CMod (.=0) if candidate==11 & A1_Can11_Table6!=3
recode CMod (.=1) if candidate==12 & A1_Can12_Table6==3
recode CMod (.=0) if candidate==12 & A1_Can12_Table6!=3
recode CMod (.=1) if candidate==13 & A1_Can13_Table7==3
recode CMod (.=0) if candidate==13 & A1_Can13_Table7!=3
recode CMod (.=1) if candidate==14 & A1_Can14_Table7==3
recode CMod (.=0) if candidate==14 & A1_Can14_Table7!=3

gen CGopM = .
recode CGopM (.=1) if candidate==1 & A1_Can1_Table1==4
recode CGopM (.=0) if candidate==1 & A1_Can1_Table1!=4
recode CGopM (.=1) if candidate==2 & A1_Can2_Table1==4
recode CGopM (.=0) if candidate==2 & A1_Can2_Table1!=4
recode CGopM (.=1) if candidate==3 & A1_Can3_Table2==4
recode CGopM (.=0) if candidate==3 & A1_Can3_Table2!=4
recode CGopM (.=1) if candidate==4 & A1_Can4_Table2==4
recode CGopM (.=0) if candidate==4 & A1_Can4_Table2!=4
recode CGopM (.=1) if candidate==5 & A1_Can5_Table3==4
recode CGopM (.=0) if candidate==5 & A1_Can5_Table3!=4
recode CGopM (.=1) if candidate==6 & A1_Can6_Table3==4
recode CGopM (.=0) if candidate==6 & A1_Can6_Table3!=4
recode CGopM (.=1) if candidate==7 & A1_Can7_Table4==4
recode CGopM (.=0) if candidate==7 & A1_Can7_Table4!=4
recode CGopM (.=1) if candidate==8 & A1_Can8_Table4==4
recode CGopM (.=0) if candidate==8 & A1_Can8_Table4!=4
recode CGopM (.=1) if candidate==9 & A1_Can9_Table5==4
recode CGopM (.=0) if candidate==9 & A1_Can9_Table5!=4
recode CGopM (.=1) if candidate==10 & A1_Can10_Table5==4
recode CGopM (.=0) if candidate==10 & A1_Can10_Table5!=4
recode CGopM (.=1) if candidate==11 & A1_Can11_Table6==4
recode CGopM (.=0) if candidate==11 & A1_Can11_Table6!=4
recode CGopM (.=1) if candidate==12 & A1_Can12_Table6==4
recode CGopM (.=0) if candidate==12 & A1_Can12_Table6!=4
recode CGopM (.=1) if candidate==13 & A1_Can13_Table7==4
recode CGopM (.=0) if candidate==13 & A1_Can13_Table7!=4
recode CGopM (.=1) if candidate==14 & A1_Can14_Table7==4
recode CGopM (.=0) if candidate==14 & A1_Can14_Table7!=4

gen CGopC = .
recode CGopC (.=1) if candidate==1 & A1_Can1_Table1==5
recode CGopC (.=0) if candidate==1 & A1_Can1_Table1!=5
recode CGopC (.=1) if candidate==2 & A1_Can2_Table1==5
recode CGopC (.=0) if candidate==2 & A1_Can2_Table1!=5
recode CGopC (.=1) if candidate==3 & A1_Can3_Table2==5
recode CGopC (.=0) if candidate==3 & A1_Can3_Table2!=5
recode CGopC (.=1) if candidate==4 & A1_Can4_Table2==5
recode CGopC (.=0) if candidate==4 & A1_Can4_Table2!=5
recode CGopC (.=1) if candidate==5 & A1_Can5_Table3==5
recode CGopC (.=0) if candidate==5 & A1_Can5_Table3!=5
recode CGopC (.=1) if candidate==6 & A1_Can6_Table3==5
recode CGopC (.=0) if candidate==6 & A1_Can6_Table3!=5
recode CGopC (.=1) if candidate==7 & A1_Can7_Table4==5
recode CGopC (.=0) if candidate==7 & A1_Can7_Table4!=5
recode CGopC (.=1) if candidate==8 & A1_Can8_Table4==5
recode CGopC (.=0) if candidate==8 & A1_Can8_Table4!=5
recode CGopC (.=1) if candidate==9 & A1_Can9_Table5==5
recode CGopC (.=0) if candidate==9 & A1_Can9_Table5!=5
recode CGopC (.=1) if candidate==10 & A1_Can10_Table5==5
recode CGopC (.=0) if candidate==10 & A1_Can10_Table5!=5
recode CGopC (.=1) if candidate==11 & A1_Can11_Table6==5
recode CGopC (.=0) if candidate==11 & A1_Can11_Table6!=5
recode CGopC (.=1) if candidate==12 & A1_Can12_Table6==5
recode CGopC (.=0) if candidate==12 & A1_Can12_Table6!=5
recode CGopC (.=1) if candidate==13 & A1_Can13_Table7==5
recode CGopC (.=0) if candidate==13 & A1_Can13_Table7!=5
recode CGopC (.=1) if candidate==14 & A1_Can14_Table7==5
recode CGopC (.=0) if candidate==14 & A1_Can14_Table7!=5

tab XTESS145, gen(type)
rename type1 oPres
rename type2 oGovr
rename type3 oMayr

tab PPETHM
gen whiteR = PPETHM
recode whiteR (2/5=0)
tab PPETHM whiteR
gen blackR = PPETHM
recode blackR (1 3/5=0) (2=1)
tab PPETHM blackR
gen hispnR = PPETHM
recode hispnR (1/3 5=0) (4=1)
tab PPETHM hispnR

logit choice cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if whiteR==1, cluster(CaseID)
logit choice cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if blackR==1, cluster(CaseID)
logit choice cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if hispnR==1, cluster(CaseID)

reg rating cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if whiteR==1, cluster(CaseID)
reg rating cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if blackR==1, cluster(CaseID)
reg rating cBlack cHispn cAsian cFemale CDemL CDemM CGopM CGopC oGovr oMayr if hispnR==1, cluster(CaseID)

*******************************************************************************************************************************
*** Combining results
*******************************************************************************************************************************

correlate choice rating if whiteR==1
correlate choice rating if blackR==1
correlate choice rating if hispnR==1
